﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.ServiceModel.Web;
using System.Text;
using System.IO;

namespace RESTful
{    
    public class Service1 : IService1
    {
        public DTO.DanhMuc_DTO[] GetCategory()
        {
            DAO.DanhMuc_DAO data = new DAO.DanhMuc_DAO();
            WebOperationContext.Current.OutgoingResponse.Headers.Add("Access-Control-Allow-Origin: *");
            return data.GetCategory();
        }

        public DTO.DataFeed_DTO[] GetFeed(String MaDanhMuc)
        {
            DAO.ChiTietDanhMuc_DAO data = new DAO.ChiTietDanhMuc_DAO();
            WebOperationContext.Current.OutgoingResponse.Headers.Add("Access-Control-Allow-Origin: *");
            return data.GetFeed(MaDanhMuc);
        }

        public DTO.FeedPersonal_DTO[] GetLink(String ID)
        {
            DAO.FeedPersonal_DAO data = new DAO.FeedPersonal_DAO();
            WebOperationContext.Current.OutgoingResponse.Headers.Add("Access-Control-Allow-Origin: *");
            return data.GetLink(ID);
        }

        public void Insert(Stream s)
        {
            DAO.FeedPersonal_DAO data = new DAO.FeedPersonal_DAO();            
            WebOperationContext.Current.OutgoingResponse.Headers.Add("Access-Control-Allow-Methods: GET, POST, PUT, DELETE");
            data.Insert(s);
        }

        public void Update(Stream s)
        {
            DAO.FeedPersonal_DAO data = new DAO.FeedPersonal_DAO();
            WebOperationContext.Current.OutgoingResponse.Headers.Add("Access-Control-Allow-Origin: *");            
            data.Update(s);
        }

        public void Delete(String MaFeed)
        {
            DAO.FeedPersonal_DAO data = new DAO.FeedPersonal_DAO();
            WebOperationContext.Current.OutgoingResponse.Headers.Add("Access-Control-Allow-Origin: *");
            data.Delete(MaFeed);
        }

        public DTO.DataFeed_DTO[] GetFeedByID(String ID)
        {
            DAO.FeedPersonal_DAO data = new DAO.FeedPersonal_DAO();
            WebOperationContext.Current.OutgoingResponse.Headers.Add("Access-Control-Allow-Origin: *");
            return data.GetFeed(ID);
        }
    }
}
